package com.next

class Product
{
    String name

    Boolean active = true

    ProductType type

    Double price
    // 单价

    // String size
    // 尺寸

    // String range
    // 规格

    // Double freight = 0
    // 运费
    
    String imageUrl

    String description

    ProductItem productItem

    Date createdDate = new Date()
    Date modifiedDate = new Date()

    static hasMany = [attachments: Attachment, productItems: ProductItem]

    static constraints = {
        name maxSize: 32, unique: true
        active nullable: true, blank: true
        type nullable: true, blank: true

        price blank: true, nullable: true
        // size blank: true, nullable: true
        // range blank: true, nullable: true
        // freight blank: true, nullable: true
        description blank: true, nullable: true
        
        productItem blank: true, nullable: true
        
        imageUrl blank: true, nullable: true
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
    }

    String toString()
    {
        name
    }
}
